﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Business.IManager;
using Business.Manager;
using Entity;
using Utility;

namespace OnlinePayment.OP
{
    public partial class PaymentPlatform : System.Web.UI.Page
    {
        IPaymentProjectManager projectManager = new PaymentProjectManager();
        IPaymentItemManager itemManager = new PaymentItemManager();
        int projectId;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["User"] == null)
            {
                //Response.Redirect("/Account/LogIn.aspx");
            }
            else
            {
                Student stu = (Student)Session["User"];
                txtStuId.Value = stu.StudentId;
                txtname.Value = stu.StudentName;
                txtclass.Value = Convert.ToString(stu.ClassNum);
                if (!IsPostBack)
                {
                    Bind();
                }
            }

        }
        protected void Bind()
        {

            paymentProjectList.DataSource = projectManager.getStudentPaymentProject(txtStuId.Value.ToString());
            if (paymentProjectList.DataSource != null)
            {
                paymentProjectList.DataBind();
            }

        }
        protected void PaymentProjectList_ItemCommand(object source, DataListCommandEventArgs e)
        {
            switch (e.CommandName)
            {
                case "Detail":
                    Response.Redirect("PaymentProjectDetail.aspx");
                   // Response.Write("<script>window.showModalDialog('PaymentProjectDetail.aspx')</script>");
                   // Page.ClientScript.RegisterStartupScript(this.GetType(), "MyScript", "alert('下单成功！'）");
                //GetDetailPaymentItem(e);
                    break;
            }
        }

        protected void GetDetailPaymentItem(DataListCommandEventArgs e)
        {
            projectId = Convert.ToInt32(e.CommandArgument.ToString());
            paymentItemList.DataSource = itemManager.getStudentDetailItem(projectId, txtStuId.Value);
            paymentItemList.DataKeyNames = new string[] { "projectId" };
            paymentItemList.DataBind();
        }
        protected void Pay_Click(object sender, EventArgs e)
        {
           
        }

        protected void lnkButChPassword_Click(object sender, EventArgs e)
        {
            Response.Redirect("/Account/ChangePassword.aspx");
        }

        protected void lnkBntMentionByMobile_Click(object sender, EventArgs e)
        {

        }

        protected void lnkBntMentionByMail_Click(object sender, EventArgs e)
        {

        }

        protected void lnkBntOff_Click(object sender, EventArgs e)
        {

        }
    }
}